package com.cartoon.adapter;

import android.graphics.Color;

import androidx.annotation.Nullable;

import com.cartoon.R;
import com.cartoon.model.CartoonTypeModel;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public  class CartoonTypeAdapter  extends BaseQuickAdapter<CartoonTypeModel, BaseViewHolder> {
    private int index ;
    public CartoonTypeAdapter(int layoutResId, @Nullable @org.jetbrains.annotations.Nullable List<CartoonTypeModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CartoonTypeModel item) {

        helper.setText(R.id.tv_type,item.getName());
        if(index==helper.getAdapterPosition()){
            helper.setTextColor(R.id.tv_type, Color.parseColor("#FFC0CB"));
            helper.setVisible(R.id.view,true);
        }else {
            helper.setTextColor(R.id.tv_type, Color.parseColor("#808080"));
            helper.setVisible(R.id.view,false);
        }
    }

    public void setIndex(int index) {
        this.index = index ;
    }
}
